<?php


include __DIR__ . "/../includes/database.php";

$date =date("Y/m/d");
$result = array();
$email = $_POST['email'];

$sql="SELECT * FROM subscribed WHERE email = '{$email}'";

$rows = mysql_query($sql,$con);
$rowcheck = mysql_num_rows($rows);

if($rowcheck > 0)
{
   $result['status'] = false;
   $result['aw'] = "The email is already subscribed";
   $result['messsages'] = "The email is already subscribed";
}
else{

	$tsql="INSERT INTO subscribed(email,date_subscribed)
	Values('{$email}','{$date}')";

	$data =  mysql_query($tsql,$con);

	sendEmail($email,"Welcome chenes eklabu","Welcome yow");
	if( $data )
	{
	   $result['status'] = true;
	}
	else
	{
	   $result['status'] = false;
	   $result['messages'] = "The email is registered";
	  
	}
}
echo json_encode($result);

?>